package com.example.pets_java.controller;

import com.example.pets_java.pojo.PetDiary;
import com.example.pets_java.service.PetDiaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/diaries")
public class PetDiaryController {

    @Autowired
    private PetDiaryService petDiaryService;

    @GetMapping("/pet/{petId}")
    public List<PetDiary> getDiariesByPetId(@PathVariable int petId) {
        return petDiaryService.getDiariesByPetId(petId);
    }

    @PostMapping("/add")
    public void addDiary(@RequestBody PetDiary petDiary) {
        petDiaryService.addDiary(petDiary);
    }
}
